package com.childmiles.gwt.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;

/**
 * A template for the app. Creates the banner and a wrapper panel for centering
 * 
 */
public class ApplicationPanel extends Composite {
    /**
     * 
     * @param mainContent for screen swapping
     */
    public ApplicationPanel(final Widget mainContent) {
        FlowPanel fullScreenContainer = new FlowPanel();
        fullScreenContainer.addStyleName("fullScreenContainer");
        
        //Header
        FlowPanel headerPanel = new FlowPanel();
        Image bannerImage = new Image("/images/banner.jpg");
        bannerImage.setTitle("Logout");
        bannerImage.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Window.Location.reload(); //cheap logout :)
            }
        });
        headerPanel.add(bannerImage);
        fullScreenContainer.add(headerPanel);
        
        //This is the widget that is switched out when we change screens
        fullScreenContainer.add(mainContent);
        
        initWidget(fullScreenContainer);
    }
}
